#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("flagman.in" , "r" , stdin);
	freopen("flagman.out" , "w" , stdout);
	int n , max = 0 , pos = 0 , a[10010];
	cin >> n;
	for(int i = 1 ; i <= n ; i++) cin >> a[i];
	for(int i = 1 ; i <= n ; i++){
		if(a[i] > max){
			max = a[i];
			pos = i;
		}
	}
	swap(a[1] , a[pos]);
	for(int i = 1 ; i <= n ; i ++) cout << a[i] << " ";
	cout << endl;
	return 0;
}